import request from '../utils/Request'
import store from '../store/index'

export function apiMiniAppLogin(params) {
  // const data = {
  //   principal: preload.type + ':' + preload.phone + ':' + preload.openId,
  //   credentials: preload.password,
  // }
  const data = {
    principal: params,
    credentials: store.getters.shopId || 0, // shopId
  }
  return request.fetch({
    url: 'login?grant_type=mini_app',
    data: data,
  })
}

export function apiGetUserInfo(preload) {
  return request.fetch({
    url: 'auth/info',
    data: preload,
  })
}

export function apiSaveUserInfo(params) {
  return request.fetch({
    url: 'auth/saveInfo',
    data: params,
  })
}

export function apiInitUserLocation(params) {
  return request.fetch({
    url: 'auth/initUserLocation',
    data: params,
  })
}
